package com.itheima.listener;

import com.itheima.service.FlowService;
import com.itheima.utils.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.stereotype.Component;

/**
 * @author 10110
 */
@Slf4j
@Component
public class MyTaskListener implements TaskListener {

    @Override
    public void notify(DelegateTask delegateTask) {

        log.info("eventName=={}", delegateTask.getEventName());

        String assignment = "assignment";

        if (assignment.equals(delegateTask.getEventName())) {

            FlowService flowService = (FlowService) SpringContextUtil.getBean("flowService");
            log.info("flowService={}", flowService);

            flowService.createTaskEvent(delegateTask);
        }

    }

}
